<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定义变量</title>
    <script>
        function f1(){
            var id;
            id = 1;
            // 在浏览器控制台打印结果
            // 相当于Java中的System.out.println()
            console.log("id:"+id);
            var name;
            name = "admin";
            console.log("name:"+name);

        }
        function f2(){
            var id = 1;
            var name = "admin";
            console.log("id:"+id+",name:"+name);
        }
    </script>
</head>
<body>
<button onclick="f1()">先声明后赋值</button><br>
<button onclick="f2()">声明的同时进行赋值</button>
</body>
</html>